package biz

import (
	"errors"
	"server/internal/data"
)

type UserBiz struct {
	repo *data.UserRepo
}

func NewUserBiz(repo *data.UserRepo) *UserBiz {
	return &UserBiz{
		repo: repo,
	}
}

func AddUser() {

}

func (ub *UserBiz) GetUserById(userId int) (*UserDO, error) {
	if userId == 0 {
		return nil, errors.New("userId invalid")
	}
	user, err := ub.repo.GetUser(userId)
	if err != nil {
		return nil, err
	}

	return &UserDO{
		Username: user.UserName,
		Age:      user.Age,
	}, err
}

type UserDO struct {
	Username string
	Age      int
}
